home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / forchek1 / iokeywds.h < prev    next >
C/C++ Source or Header  |  1991-11-05  |  4KB  |  119 lines

  1. /* iokeywds.h:
  2.       Contains definitions of I/O control-list specifier keywords
  3.       and their properties.  If VMS or VMS_IO is defined, supports
  4.       many VMS-specific keywords needed to deal with VMS files.
  5.       (Suppressed if NO_VMS_IO is defined.)  You may add other
  6.       locally supported specifiers as appropriate (order is not
  7.       important).
  8.  
  9.     Copyright (C) 1991 by Robert K. Moniot.
  10.     This program is free software.  Permission is granted to
  11.     modify it and/or redistribute it, retaining this notice.
  12.     No guarantees accompany this software.
  13.  
  14.  
  15. */
  16.  
  17.  
  18.  
  19.  /* Define bit flag for each I/O command */
  20. #define RD  0x1   /* read */
  21. #define WR  0x2   /* write */
  22. #define OP  0x4   /* open */
  23. #define CL  0x8   /* close */
  24. #define INQ 0x10  /* inquire */
  25. #define BSP 0x20  /* backspace */
  26. #define ENF 0x40  /* endfile */
  27. #define REW 0x80  /* rewind */
  28. #define ALL (RD|WR|OP|CL|INQ|BSP|ENF|REW)
  29.  
  30.  /* Define bit flag for each type of specifier value.  All types
  31.     (see symtab.h) are < 16 so these values will fit in a short.*/
  32. #define LAB (1<<type_LABEL) /* label */
  33. #define CHR (1<<type_STRING) /* character */
  34. #define INT (1<<type_INTEGER) /* integer */
  35. #define LOG (1<<type_LOGICAL) /* logical */
  36. #define STAR (1<<type_UNDECL) /* does duty for '*' */
  37. #define FID (LAB|CHR|STAR) /* format ID */
  38. #define UID (INT|CHR|STAR) /* unit ID */
  39.  
  40.  
  41. struct {
  42.     char *name;   /* Name of keyword */
  43.     unsigned short allowed_stmts, /* Where keyword can occur */
  44.          allowed_types; /* datatypes allowed for value */
  45.     unsigned  /* Flags for handling the specifier value */
  46.       implies_use: 1,  /* Value is used */
  47.       implies_set: 1,  /* Var is set (except INQUIRE) */
  48.       inquire_set: 1,  /* Var is set by INQUIRE */
  49.       nonstandard: 1,  /* not Fortran 77 standard keyword */
  50.       special:    1;  /* Indicates special cases */
  51. } io_keywords[]={
  52.    /* List has commonest ones first for fast lookup */
  53. /*Name        Stmts   Types   UseSetInqStdSpcl */
  54. {"END",  RD, LAB, 1, 0, 0, 0, 0},
  55. {"ERR",  ALL, LAB, 1, 0, 0, 0, 0},
  56. {"FILE", OP|INQ, CHR, 1, 0, 0, 0, 0},
  57. {"UNIT", ALL, UID, 1, 0, 0, 0, 0},
  58. {"STATUS", OP|CL, CHR, 1, 0, 0, 0, 0},
  59.    /* The rest are alphabetical. */
  60. {"ACCESS", OP|INQ, CHR, 1, 0, 1, 0, 0},
  61. {"BLANK", OP|INQ, CHR, 1, 0, 1, 0, 0},
  62. {"DIRECT", INQ, CHR, 0, 0, 1, 0, 0},
  63. {"EXIST", INQ, LOG, 0, 0, 1, 0, 0},
  64. {"FMT",  RD|WR, FID, 1, 0, 0, 0, 0},
  65. {"FORM", OP|INQ, CHR, 1, 0, 1, 0, 0},
  66. {"FORMATTED", INQ, CHR, 0, 0, 1, 0, 0},
  67. {"IOSTAT", ALL, INT, 0, 1, 1, 0, 0},
  68. {"NAMED", INQ, LOG, 0, 0, 1, 0, 0},
  69. {"NEXTREC", INQ, INT, 0, 0, 1, 0, 0},
  70. {"NUMBER", INQ, INT, 0, 0, 1, 0, 0},
  71. {"OPENED", INQ, LOG, 0, 0, 1, 0, 0},
  72. {"REC",  RD|WR, INT, 1, 0, 0, 0, 0},
  73. {"RECL", OP|INQ, INT, 1, 0, 1, 0, 0},
  74. {"SEQUENTIAL", INQ, CHR, 0, 0, 1, 0, 0},
  75. {"UNFORMATTED", INQ, CHR, 0, 0, 1, 0, 0},
  76.    /* NAME is a special case for VMS */
  77. #ifndef VMS_IO
  78. {"NAME", INQ, CHR, 0, 0, 1, 0, 0}, /* normal definition */
  79. #else
  80. {"NAME", OP|INQ, CHR, 1, 0, 1, 0, 1}, /* VMS definition */
  81. #endif /*VMS_IO*/
  82.    /* Other simple VMS-isms go here. */
  83. #ifdef VMS_IO
  84. {"BLOCKSIZE", OP, INT, 1, 0, 0, 1, 0},
  85. {"BUFFERCOUNT", OP, INT, 1, 0, 0, 1, 0},
  86. {"CARRIAGECONTROL",OP|INQ,CHR, 1, 0, 1, 1, 0},
  87. {"DEFAULTFILE", OP, CHR, 1, 0, 0, 1, 0},
  88. {"DISP", OP|CL, CHR, 1, 0, 0, 1, 0},
  89. {"DISPOSE", OP|CL, CHR, 1, 0, 0, 1, 0},
  90. {"EXTENDSIZE", OP, INT, 1, 0, 0, 1, 0},
  91. {"INITIALSIZE", OP, INT, 1, 0, 0, 1, 0},
  92. {"MAXREC", OP, INT, 1, 0, 0, 1, 0},
  93. {"ORGANIZATION",OP|INQ, CHR, 1, 0, 1, 1, 0},
  94. {"RECORDSIZE", OP, INT, 1, 0, 0, 1, 0},
  95. {"RECORDTYPE", OP|INQ, CHR, 1, 0, 1, 1, 0},
  96. {"TYPE", OP, CHR, 1, 0, 0, 1, 0},
  97. #endif /*VMS_IO*/
  98.    /* Last entry (for not-founds) has defns that should
  99.       do the right thing most of the time. */
  100. {NULL,  ALL, (~0), 1, 0, 1, 1, 0},
  101. };
  102.  
  103.  /* Lookup table which maps statement classes into
  104.     the corresponding bit fields of io_keywords table.
  105.     Order: commonest first for faster lookup. */
  106. struct {
  107.  short stmt_class, stmt_flag;
  108. } local_class[]= {
  109. {tok_READ,  RD},
  110. {tok_WRITE,  WR},
  111. {tok_OPEN,  OP},
  112. {tok_CLOSE,  CL},
  113. {tok_BACKSPACE,  BSP},
  114. {tok_ENDFILE,  ENF},
  115. {tok_REWIND,  REW},
  116. {tok_INQUIRE,  INQ},
  117. };
  118. #define NUM_IO_STMTS (sizeof(local_class)/sizeof(local_class[0]))
  119.